package model;

import util.DBUtil;

import java.util.List;
import java.util.Map;

public class FoodTypeService {
    private DBUtil db;

    public FoodTypeService() {
        db = new DBUtil();
    }

    public List<Map<String, String>> getAllTypes() {
        String sql = "select * from foodtype";
        return db.getList(sql);
    }

    //添加食品种类
    public int addFoodType(String typeName) {
        String sql = "insert into foodtype values(null,?)";
        return db.update(sql, new String[]{typeName});
    }

    //根据id删除食品种类
    public int deleteFoodType(String id) {
        String sql = "delete from foodtype where id=?";
        return db.update(sql, new String[]{id});
    }

    //测试addFoodType
//    public static void main(String[] args) {
//        FoodTypeService foodTypeService = new FoodTypeService();
//        foodTypeService.addFoodType("热菜1");
//    }

}
